﻿using Newtonsoft.Json;
using Omabar.BLL;
using Omabar.Common;
using Omabar.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;

namespace Omabar.CMS.Handler
{
    /// <summary>
    /// FoodAdd 的摘要说明
    /// </summary>
    public class FoodAdd : IHttpHandler, IRequiresSessionState
    {
        public void ProcessRequest(HttpContext context)
        {
            RESP_Info info = new RESP_Info();
            try
            {
                context.Response.ContentType = "text/plain";
                string BREAKFAST = context.Request["BREAKFAST"];
                string LUNCH = context.Request["LUNCH"];
                string DINNER = context.Request["DINNER"];

                FOOD food = new FOOD()
                {
                    FOOD_ID = Util.GetUID(),
                    BREAKFAST = BREAKFAST,
                    LUNCH = LUNCH,
                    DINNER = DINNER
                };

                Food_BLL bll = new Food_BLL();
                info = bll.Add(food);
            }
            catch (Exception ex)
            {
                Tom.Net.Log.LogManager.Error("添加餐饮失败", ex);
                info.Success = false;
                info.Title = "错误";
                info.Tip = "<h5><p>添加餐饮失败</p></h5>";
                info.Url = "FoodAdd.aspx";
            }

            context.Response.Write(JsonConvert.SerializeObject(info));
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}